#!/usr/bin/env python
# coding=utf-8
# __author__ = 'Yunchao Ling'

import sys

FILE_NAME = sys.argv[1]
EACH_PART_NUMBER = int(sys.argv[2])

current_task_id = 1
count = 0
total_line = ""

infile = open(FILE_NAME, 'r')
for line in infile:
    line = line.rstrip()
    total_line += line + "\n"
    count += 1
    if count == EACH_PART_NUMBER:
        outfile = open(FILE_NAME + "." + str(current_task_id) + ".task", 'w')
        outfile.write(total_line)
        outfile.flush()
        outfile.close()
        total_line = ""
        count = 0
        current_task_id += 1
infile.close()
if total_line != "":
    outfile = open(FILE_NAME + "." + str(current_task_id) + ".task", 'w')
    outfile.write(total_line)
    outfile.flush()
    outfile.close()
